[IA64] cleanup
authorawilliam@xenbuild.aw <awilliam@xenbuild.aw>
Mon, 14 Aug 2006 19:42:00 +0000 (13:42 -0600)
committerawilliam@xenbuild.aw <awilliam@xenbuild.aw>
Mon, 14 Aug 2006 19:42:00 +0000 (13:42 -0600)
Cleanup of the week:
Perf counters added.
Use BUILD_BUG_ON instead of #error+macros.
CPL is checked before calling ia64_hypercall().
Reformatting in hypercall.c
multicall now check hypercall number.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
xen/arch/ia64/asm-offsets.c
xen/arch/ia64/linux-xen/irq_ia64.c
xen/arch/ia64/linux-xen/smp.c
xen/arch/ia64/xen/faults.c
xen/arch/ia64/xen/hypercall.c
xen/arch/ia64/xen/irq.c
xen/arch/ia64/xen/privop.c
xen/arch/ia64/xen/xensetup.c
xen/include/asm-ia64/dom_fw.h
xen/include/asm-ia64/linux-xen/asm/processor.h
xen/include/asm-ia64/multicall.h

index f100c5f1536b6177141f8da4a15a71c1f0edd98d..67b5725c564c338f7d0d466838b292a29df538fb 100644 (file)
@@ -31,7 +31,6 @@ void foo(void)
        DEFINE(IA64_SWITCH_STACK_SIZE, sizeof (struct switch_stack));
        DEFINE(IA64_CPU_SIZE, sizeof (struct cpuinfo_ia64));
        DEFINE(UNW_FRAME_INFO_SIZE, sizeof (struct unw_frame_info));
-       DEFINE(SHARED_INFO_SIZE, sizeof (struct shared_info));
        DEFINE(MAPPED_REGS_T_SIZE, sizeof (mapped_regs_t));
 
        BLANK();
index ca2473a9ffa489e80478f90dc2ce11bbed5e1a70..dccecdf250899f0c42311ff7cb8ac2484a471e2d 100644 (file)
@@ -108,6 +108,9 @@ ia64_handle_irq (ia64_vector vector, struct pt_regs *regs)
 {
        unsigned long saved_tpr;
 
+#ifdef XEN
+       perfc_incrc(irqs);
+#endif
 #if IRQ_DEBUG
 #ifdef XEN
        xen_debug_irq(vector, regs);
@@ -290,8 +293,5 @@ ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect)
        ipi_data = (delivery_mode << 8) | (vector & 0xff);
        ipi_addr = ipi_base_addr + ((phys_cpu_id << 4) | ((redirect & 1) << 3));
 
-#ifdef XEN
-       //printf ("send_ipi to %d (%x)\n", cpu, phys_cpu_id);
-#endif
        writeq(ipi_data, ipi_addr);
 }
index 8801d28f64ada25491bee3c232231705ecef4119..67b80710f7c1b81b42ed6ddb950f27083d6be1b4 100644 (file)
@@ -146,6 +146,9 @@ handle_IPI (int irq, void *dev_id, struct pt_regs *regs)
        unsigned long *pending_ipis = &__ia64_per_cpu_var(ipi_operation);
        unsigned long ops;
 
+#ifdef XEN
+       perfc_incrc(ipis);
+#endif
        mb();   /* Order interrupt and bit testing. */
        while ((ops = xchg(pending_ipis, 0)) != 0) {
                mb();   /* Order bit clearing and data access. */
index 16bef26b31d840d57d4e9c41588c7d7452825746..171fddd0410ac569dd56ce003090274ddfe1fb72 100644 (file)
@@ -515,7 +515,8 @@ ia64_handle_break (unsigned long ifa, struct pt_regs *regs, unsigned long isr, u
                debugger_trap_fatal(0 /* don't care */, regs);
        } 
 #endif
-       else if (iim == d->arch.breakimm) {
+       else if (iim == d->arch.breakimm &&
+                ia64_get_cpl(regs->cr_ipsr) == 2) {
                /* by default, do not continue */
                v->arch.hypercall_continuation = 0;
 
index 6fcc1ef72e625d840d704c3248bd1715a7cf7d94..46d279b5b28437e5d788196e4c2d12dd8c420a9d 100644 (file)
@@ -33,75 +33,81 @@ static long do_physdev_op_compat(XEN_GUEST_HANDLE(physdev_op_t) uop);
 static long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg);
 static long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg);
 
-hypercall_t ia64_hypercall_table[] =
-       {
-       (hypercall_t)do_ni_hypercall,           /* do_set_trap_table */         /*  0 */
+const hypercall_t ia64_hypercall_table[NR_hypercalls] =
+{
+       (hypercall_t)do_ni_hypercall,           /* do_set_trap_table *//*  0 */
        (hypercall_t)do_ni_hypercall,           /* do_mmu_update */
        (hypercall_t)do_ni_hypercall,           /* do_set_gdt */
        (hypercall_t)do_ni_hypercall,           /* do_stack_switch */
        (hypercall_t)do_ni_hypercall,           /* do_set_callbacks */
-       (hypercall_t)do_ni_hypercall,           /* do_fpu_taskswitch */         /*  5 */
+       (hypercall_t)do_ni_hypercall,           /* do_fpu_taskswitch *//*  5 */
        (hypercall_t)do_sched_op_compat,
        (hypercall_t)do_dom0_op,
        (hypercall_t)do_ni_hypercall,           /* do_set_debugreg */
        (hypercall_t)do_ni_hypercall,           /* do_get_debugreg */
-       (hypercall_t)do_ni_hypercall,           /* do_update_descriptor */      /* 10 */
+       (hypercall_t)do_ni_hypercall,           /* do_update_descriptor * 10 */
        (hypercall_t)do_ni_hypercall,           /* do_ni_hypercall */
        (hypercall_t)do_memory_op,
        (hypercall_t)do_multicall,
        (hypercall_t)do_ni_hypercall,           /* do_update_va_mapping */
-       (hypercall_t)do_ni_hypercall,           /* do_set_timer_op */           /* 15 */
+       (hypercall_t)do_ni_hypercall,           /* do_set_timer_op */  /* 15 */
        (hypercall_t)do_event_channel_op_compat,
        (hypercall_t)do_xen_version,
        (hypercall_t)do_console_io,
        (hypercall_t)do_physdev_op_compat,
-       (hypercall_t)do_grant_table_op,                                         /* 20 */
+       (hypercall_t)do_grant_table_op,                                /* 20 */
        (hypercall_t)do_ni_hypercall,           /* do_vm_assist */
-       (hypercall_t)do_ni_hypercall,           /* do_update_va_mapping_otherdomain */
+       (hypercall_t)do_ni_hypercall,           /* do_update_va_mapping_othe */
        (hypercall_t)do_ni_hypercall,           /* (x86 only) */
        (hypercall_t)do_ni_hypercall,           /* do_vcpu_op */
-       (hypercall_t)do_ni_hypercall,           /* (x86_64 only) */             /* 25 */
+       (hypercall_t)do_ni_hypercall,           /* (x86_64 only) */    /* 25 */
        (hypercall_t)do_ni_hypercall,           /* do_mmuext_op */
        (hypercall_t)do_ni_hypercall,           /* do_acm_op */
        (hypercall_t)do_ni_hypercall,           /* do_nmi_op */
        (hypercall_t)do_sched_op,
-       (hypercall_t)do_callback_op,            /*  */                  /* 30 */
+       (hypercall_t)do_callback_op,            /*  */                 /* 30 */
        (hypercall_t)do_ni_hypercall,           /*  */
        (hypercall_t)do_event_channel_op,
        (hypercall_t)do_physdev_op,
        (hypercall_t)do_hvm_op,                 /*  */
-       (hypercall_t)do_ni_hypercall,           /*  */                  /* 35 */
+       (hypercall_t)do_ni_hypercall,           /*  */                 /* 35 */
        (hypercall_t)do_ni_hypercall,           /*  */
        (hypercall_t)do_ni_hypercall,           /*  */
        (hypercall_t)do_ni_hypercall,           /*  */
        (hypercall_t)do_ni_hypercall,           /*  */
-       (hypercall_t)do_ni_hypercall,           /*  */                  /* 40 */
+       (hypercall_t)do_ni_hypercall,           /*  */                 /* 40 */
        (hypercall_t)do_ni_hypercall,           /*  */
        (hypercall_t)do_ni_hypercall,           /*  */
        (hypercall_t)do_ni_hypercall,           /*  */
        (hypercall_t)do_ni_hypercall,           /*  */
-       (hypercall_t)do_ni_hypercall,           /*  */                  /* 45 */
+       (hypercall_t)do_ni_hypercall,           /*  */                 /* 45 */
        (hypercall_t)do_ni_hypercall,           /*  */
        (hypercall_t)do_ni_hypercall,           /*  */
-       (hypercall_t)do_dom0vp_op,                      /* dom0vp_op */
+       (hypercall_t)do_dom0vp_op,              /* dom0vp_op */
        (hypercall_t)do_ni_hypercall,           /* arch_1 */
-       (hypercall_t)do_ni_hypercall,           /* arch_2 */            /* 50 */
+       (hypercall_t)do_ni_hypercall,           /* arch_2 */           /* 50 */
        (hypercall_t)do_ni_hypercall,           /* arch_3 */
        (hypercall_t)do_ni_hypercall,           /* arch_4 */
        (hypercall_t)do_ni_hypercall,           /* arch_5 */
        (hypercall_t)do_ni_hypercall,           /* arch_6 */
-       (hypercall_t)do_ni_hypercall            /* arch_7 */            /* 55 */
-       };
-
-uint32_t nr_hypercalls =
-       sizeof(ia64_hypercall_table) / sizeof(hypercall_t);
+       (hypercall_t)do_ni_hypercall,           /* arch_7 */           /* 55 */
+       (hypercall_t)do_ni_hypercall,
+       (hypercall_t)do_ni_hypercall,
+       (hypercall_t)do_ni_hypercall,
+       (hypercall_t)do_ni_hypercall,
+       (hypercall_t)do_ni_hypercall,                                  /* 60 */
+       (hypercall_t)do_ni_hypercall,
+       (hypercall_t)do_ni_hypercall,
+       (hypercall_t)do_ni_hypercall
+};
 
 static IA64FAULT
 xen_hypercall (struct pt_regs *regs)
 {
        uint32_t cmd = (uint32_t)regs->r2;
 
-       if (cmd < nr_hypercalls)
+       if (cmd < NR_hypercalls) {
+               perfc_incra(hypercalls, cmd);
                regs->r8 = (*ia64_hypercall_table[cmd])(
                        regs->r14,
                        regs->r15,
@@ -109,13 +115,12 @@ xen_hypercall (struct pt_regs *regs)
                        regs->r17,
                        regs->r18,
                        regs->r19);
-       else
+       else
                regs->r8 = -ENOSYS;
 
        return IA64_NO_FAULT;
 }
 
-
 static void
 fw_hypercall_ipi (struct pt_regs *regs)
 {
@@ -277,18 +282,7 @@ fw_hypercall (struct pt_regs *regs)
 IA64FAULT
 ia64_hypercall (struct pt_regs *regs)
 {
-       struct vcpu *v = current;
        unsigned long index = regs->r2;
-       int privlvl = (regs->cr_ipsr & IA64_PSR_CPL) >> IA64_PSR_CPL0_BIT;
-
-       /* Hypercalls are only allowed by kernel.
-          Kernel checks memory accesses.  */
-       if (VMX_DOMAIN(v) ? (privlvl != 0) : (privlvl != 2)) {
-           /* FIXME: Return a better error value ?
-              Reflection ? Illegal operation ?  */
-           regs->r8 = -1;
-           return IA64_NO_FAULT;
-       }
 
        if (index >= FW_HYPERCALL_FIRST_ARCH)
            return fw_hypercall (regs);
index 26af99a7e579f10b96f9086505f5687d654cce4f..7dd075cd1dec7bfd9df6b77e7c1e29aeb0f1febd 100644 (file)
@@ -236,9 +236,6 @@ int setup_vector(unsigned int irq, struct irqaction * new)
        struct irqaction *old, **p;
        irq_desc_t *desc = irq_descp(irq);
 
-       printf ("setup_vector(%d): handler=%p, flags=%x\n",
-               irq, desc->handler, desc->status);
-
        /*
         * The following block of code has to be executed atomically
         */
index 2053317e51240a8bb513548ae9917e049cabb50b..a66e2153219b519b0abd36669d1f3abda6784b32 100644 (file)
@@ -681,7 +681,7 @@ priv_emulate(VCPU *vcpu, REGS *regs, UINT64 isr)
                return IA64_ILLOP_FAULT;
        }
        //if (isrcode != 1 && isrcode != 2) return 0;
-       privlvl = (ipsr & IA64_PSR_CPL) >> IA64_PSR_CPL0_BIT;
+       privlvl = ia64_get_cpl(ipsr);
        // its OK for a privified-cover to be executed in user-land
        fault = priv_handle_op(vcpu,regs,privlvl);
        if ((fault == IA64_NO_FAULT) || (fault == IA64_EXTINT_VECTOR)) { // success!!
index 2120c1ebf4c646ffb44b51fd710a0eaa8c134f4c..c9830575bf9e72cb8dfa3d476349af08a730ea17 100644 (file)
 #include <linux/efi.h>
 #include <asm/iosapic.h>
 
-/* Be sure the struct shared_info size is <= XSI_SIZE.  */
-#if SHARED_INFO_SIZE > XSI_SIZE
-#error "struct shared_info bigger than XSI_SIZE"
-#endif
-
 unsigned long xenheap_phys_end, total_pages;
 
 char saved_command_line[COMMAND_LINE_SIZE];
@@ -258,6 +253,9 @@ void start_kernel(void)
     int i;
 #endif
 
+    /* Be sure the struct shared_info size is <= XSI_SIZE.  */
+    BUILD_BUG_ON(sizeof(struct shared_info) > XSI_SIZE);
+
     running_on_sim = is_platform_hp_ski();
     /* Kernel may be relocated by EFI loader */
     xen_pstart = ia64_tpa(KERNEL_START);
index 49980dc15d57bd8fe7b8041326e1a5a4780ea0b4..10d7c2e380b3b638dadee4b65be7ab16724cdc84 100644 (file)
 
 /* Hypercalls index bellow _FIRST_ARCH are reserved by Xen, while those above
    are for the architecture.
-   Note: this limit was defined by Xen/ia64 (and not by Xen).²
+   Note: this limit was defined by Xen/ia64 (and not by Xen).
      This can be renumbered safely.
 */
 #define FW_HYPERCALL_FIRST_ARCH                0x300UL
 
-/* Xen/ia64 user hypercalls.  Only used for debugging.  */
-#define FW_HYPERCALL_FIRST_USER                0xff00UL
-
 /* Interrupt vector used for os boot rendez vous.  */
 #define XEN_SAL_BOOT_RENDEZ_VEC        0xF3
 
index 1a713f4a0d34266a78dca8ec0e45a9e7d1456db7..65f65538bc1a901d92ce83ecccb19e8c1d172d4c 100644 (file)
@@ -717,6 +717,14 @@ prefetchw (const void *x)
 
 extern unsigned long boot_option_idle_override;
 
+#ifdef XEN
+static inline unsigned int
+ia64_get_cpl(unsigned long psr)
+{
+  return (psr & IA64_PSR_CPL) >> IA64_PSR_CPL0_BIT;
+}
+#endif
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* _ASM_IA64_PROCESSOR_H */
index 53bb171c326dbfe711d08eed37be17046d8fff00..ea104e5efa0915933c48396fbef8fcb464a22ac6 100644 (file)
@@ -11,17 +11,20 @@ typedef unsigned long (*hypercall_t)(
                        unsigned long arg4,
                        unsigned long arg5);
 
-extern hypercall_t ia64_hypercall_table[];
+extern const hypercall_t ia64_hypercall_table[];
 
 static inline void do_multicall_call(multicall_entry_t *call)
 {
-       call->result = (*ia64_hypercall_table[call->op])(
+       if (call->op < NR_hypercalls)
+               call->result = (*ia64_hypercall_table[call->op])(
                        call->args[0],
                        call->args[1],
                        call->args[2],
                        call->args[3],
                        call->args[4],
                        call->args[5]);
+       else
+               call->result = -ENOSYS;
 }
 
 #endif /* __ASM_IA64_MULTICALL_H__ */